<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>树洞详情 - 发现真实的声音</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: #4F46E5;
            --primary-light: #EEF2FF;
            --secondary: #EC4899;
            --secondary-light: #FCE7F3;
            --dark: #1F2937;
            --light: #F9FAFB;
            --gray: #6B7280;
            --border: #E5E7EB;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            --shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        
        body {
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            background-color: #F3F4F6;
            color: var(--dark);
            line-height: 1.6;
        }
        
        .container {
            max-width: 900px;
        }
        
        /* 导航栏样式 */
        .navbar {
            background-color: white;
            box-shadow: var(--shadow);
            padding: 0.75rem 1rem;
        }
        
        .navbar-brand {
            font-weight: 700;
            color: var(--primary);
            font-size: 1.5rem;
        }
        
        .nav-link {
            color: var(--dark);
            margin-left: 1rem;
            font-weight: 500;
            transition: color 0.2s;
        }
        
        .nav-link:hover, .nav-link.active {
            color: var(--primary);
        }
        
        /* 主内容区样式 */
        .main-content {
            padding: 2rem 0;
        }
        
        /* 树洞详情卡片 */
        .post-detail-card {
            background-color: white;
            border-radius: 12px;
            box-shadow: var(--shadow);
            overflow: hidden;
            margin-bottom: 2rem;
        }
        
        .post-header {
            padding: 1.5rem;
            display: flex;
            align-items: center;
            gap: 1rem;
            border-bottom: 1px solid var(--border);
        }
        
        .author-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            object-fit: cover;
        }
        
        .author-info {
            flex: 1;
        }
        
        .author-name {
            font-weight: 600;
            font-size: 1.1rem;
        }
        
        .post-meta {
            font-size: 0.9rem;
            color: var(--gray);
            display: flex;
            flex-wrap: wrap;
            gap: 1rem;
        }
        
        .post-status {
            display: inline-block;
            padding: 0.2rem 0.6rem;
            background-color: var(--primary-light);
            color: var(--primary);
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
        }
        
        .post-content {
            padding: 1.5rem;
            font-size: 1.1rem;
            line-height: 1.8;
        }
        
        .post-gallery {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 0.5rem;
            margin-bottom: 1rem;
        }
        
        .post-image {
            width: 100%;
            border-radius: 8px;
            object-fit: cover;
            cursor: pointer;
            transition: transform 0.2s;
        }
        
        .post-image:hover {
            transform: scale(1.02);
        }
        
        .post-tags {
            padding: 0 1.5rem 1rem;
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;
        }
        
        .post-tag {
            padding: 0.3rem 0.8rem;
            background-color: var(--light);
            border-radius: 20px;
            font-size: 0.85rem;
            color: var(--gray);
        }
        
        .post-actions {
            padding: 1rem 1.5rem;
            display: flex;
            justify-content: space-between;
            border-top: 1px solid var(--border);
            background-color: var(--light);
        }
        
        .action-btn {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--gray);
            background: none;
            border: none;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 0.95rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .action-btn:hover {
            color: var(--primary);
            background-color: rgba(79, 70, 229, 0.05);
        }
        
        .action-btn.liked {
            color: var(--secondary);
        }
        
        .action-btn.saved {
            color: var(--primary);
        }
        
        /* 评论区样式 */
        .comments-section {
            background-color: white;
            border-radius: 12px;
            box-shadow: var(--shadow);
            padding: 1.5rem;
            margin-bottom: 2rem;
        }
        
        .comments-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid var(--border);
        }
        
        .comments-title {
            font-weight: 600;
            font-size: 1.25rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .comments-count {
            color: var(--primary);
            background-color: var(--primary-light);
            padding: 0.1rem 0.5rem;
            border-radius: 10px;
            font-size: 0.85rem;
        }
        
        .sort-comments {
            color: var(--gray);
            font-size: 0.9rem;
            cursor: pointer;
        }
        
        /* 评论输入框 */
        .comment-input-container {
            display: flex;
            gap: 1rem;
            margin-bottom: 2rem;
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
        }
        
        .comment-input-wrapper {
            flex: 1;
        }
        
        .comment-input {
            width: 100%;
            padding: 0.8rem 1rem;
            border: 1px solid var(--border);
            border-radius: 8px;
            resize: none;
            font-size: 0.95rem;
            transition: border-color 0.2s;
        }
        
        .comment-input:focus {
            outline: none;
            border-color: var(--primary);
        }
        
        .comment-actions {
            display: flex;
            justify-content: flex-end;
            margin-top: 0.75rem;
            gap: 1rem;
        }
        
        .cancel-btn {
            padding: 0.5rem 1.25rem;
            background-color: white;
            border: 1px solid var(--border);
            border-radius: 6px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .cancel-btn:hover {
            background-color: var(--light);
        }
        
        .submit-btn {
            padding: 0.5rem 1.25rem;
            background-color: var(--primary);
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .submit-btn:hover {
            background-color: #4338CA;
        }
        
        /* 评论列表 */
        .comments-list {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }
        
        .comment-item {
            display: flex;
            gap: 1rem;
        }
        
        .comment-content-wrapper {
            flex: 1;
        }
        
        .comment-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.5rem;
        }
        
        .comment-author {
            font-weight: 600;
            font-size: 0.95rem;
        }
        
        .comment-time {
            font-size: 0.8rem;
            color: var(--gray);
        }
        
        .comment-text {
            background-color: var(--light);
            padding: 0.8rem 1rem;
            border-radius: 8px;
            margin-bottom: 0.75rem;
            position: relative;
        }
        
        .comment-text:before {
            content: '';
            position: absolute;
            left: -8px;
            top: 12px;
            width: 16px;
            height: 16px;
            background-color: var(--light);
            transform: rotate(45deg);
            z-index: 0;
        }
        
        .comment-actions {
            display: flex;
            gap: 1.5rem;
            font-size: 0.85rem;
        }
        
        .comment-action {
            display: flex;
            align-items: center;
            gap: 4px;
            color: var(--gray);
            cursor: pointer;
            transition: color 0.2s;
        }
        
        .comment-action:hover {
            color: var(--primary);
        }
        
        .comment-action.liked {
            color: var(--secondary);
        }
        
        /* 回复样式 */
        .replies-list {
            margin-top: 1rem;
            margin-left: 2.5rem;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }
        
        .reply-item {
            display: flex;
            gap: 0.75rem;
        }
        
        .reply-content-wrapper {
            flex: 1;
        }
        
        .reply-text {
            background-color: var(--light);
            padding: 0.6rem 0.8rem;
            border-radius: 6px;
            margin-bottom: 0.5rem;
            font-size: 0.9rem;
        }
        
        .reply-to {
            color: var(--primary);
            font-weight: 500;
        }
        
        /* 回复输入框 */
        .reply-input-container {
            display: flex;
            gap: 0.75rem;
            margin-top: 0.75rem;
        }
        
        .reply-input {
            flex: 1;
            padding: 0.6rem 0.8rem;
            border: 1px solid var(--border);
            border-radius: 6px;
            resize: none;
            font-size: 0.9rem;
            transition: border-color 0.2s;
        }
        
        .reply-input:focus {
            outline: none;
            border-color: var(--primary);
        }
        
        .reply-actions {
            display: flex;
            justify-content: flex-end;
            gap: 0.75rem;
            margin-top: 0.5rem;
        }
        
        .reply-btn {
            padding: 0.3rem 0.8rem;
            font-size: 0.85rem;
        }
        
        /* 相关推荐 */
        .related-posts {
            margin-top: 3rem;
        }
        
        .related-title {
            font-weight: 600;
            font-size: 1.25rem;
            margin-bottom: 1.5rem;
        }
        
        .related-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 1.25rem;
        }
        
        .related-card {
            background-color: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: var(--shadow);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .related-card:hover {
            transform: translateY(-3px);
            box-shadow: var(--shadow-hover);
        }
        
        .related-image {
            width: 100%;
            height: 140px;
            object-fit: cover;
        }
        
        .related-content {
            padding: 1rem;
        }
        
        .related-text {
            font-size: 0.95rem;
            margin-bottom: 0.75rem;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .related-meta {
            display: flex;
            justify-content: space-between;
            font-size: 0.8rem;
            color: var(--gray);
        }
        
        /* 浮动发布按钮 */
        .float-post-btn {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background-color: var(--primary);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
            border: none;
            cursor: pointer;
            transition: transform 0.2s;
        }
        
        .float-post-btn:hover {
            transform: scale(1.1);
        }
        
        /* 图片查看器 */
        .image-viewer {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.9);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        
        .image-viewer.show {
            display: flex;
        }
        
        .viewer-content {
            position: relative;
            max-width: 90%;
            max-height: 90%;
        }
        
        .viewer-image {
            max-width: 100%;
            max-height: 80vh;
            object-fit: contain;
        }
        
        .close-viewer {
            position: absolute;
            top: -40px;
            right: 0;
            color: white;
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
        }
        
        .viewer-nav {
            position: absolute;
            top: 50%;
            width: 100%;
            display: flex;
            justify-content: space-between;
            transform: translateY(-50%);
        }
        
        .viewer-btn {
            color: white;
            background: none;
            border: none;
            font-size: 2rem;
            cursor: pointer;
            padding: 1rem;
            opacity: 0.7;
            transition: opacity 0.2s;
        }
        
        .viewer-btn:hover {
            opacity: 1;
        }
        
        /* 响应式调整 */
        @media (max-width: 768px) {
            .post-gallery {
                grid-template-columns: 1fr;
            }
            
            .post-actions {
                flex-wrap: wrap;
                gap: 0.5rem;
            }
            
            .action-btn {
                flex: 1;
                justify-content: center;
                padding: 8px;
            }
            
            .related-list {
                grid-template-columns: 1fr;
            }
            
            .comment-text:before {
                display: none;
            }
            
            .replies-list {
                margin-left: 1rem;
            }
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg">
        <div class="container">
            <a class="navbar-brand" href="#">树洞</a>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link active" aria-current="page" href="#"><i class="fas fa-home me-1"></i> 首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#"><i class="fas fa-compass me-1"></i> 发现</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#"><i class="far fa-bell me-1"></i> 通知</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#"><i class="far fa-user me-1"></i> 我的</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    
    <div class="container main-content">
        <!-- 树洞详情卡片 -->
        <div class="post-detail-card">
            <div class="post-header">
                <img src="https://picsum.photos/100/100?random=1" alt="用户头像" class="author-avatar">
                <div class="author-info">
                    <div class="author-name">匿名用户753</div>
                    <div class="post-meta">
                        <span><i class="far fa-clock me-1"></i> 2小时前</span>
                        <span><i class="far fa-eye me-1"></i> 356</span>
                        <span><i class="far fa-comment me-1"></i> 24</span>
                        <span><i class="fas fa-tag me-1"></i> 职场</span>
                        <span class="post-status">热门讨论</span>
                    </div>
                </div>
            </div>
            
            <div class="post-content">
                今天终于鼓起勇气辞职了，虽然不知道未来会怎样，但至少摆脱了那个令人窒息的工作环境。每天加班到深夜，领导只会画饼，同事之间勾心斗角，感觉自己快要抑郁了。<br><br>

                也许休息一段时间，重新思考一下自己真正想做什么会更好。有没有同样经历的人，能给我一点建议？
            </div>
            
            <div class="post-tags">
                <span class="post-tag">#职场压力</span>
                <span class="post-tag">#辞职</span>
                <span class="post-tag">#职业规划</span>
                <span class="post-tag">#职场困境</span>
            </div>
            
            <div class="post-actions">
                <button class="action-btn like-btn">
                    <i class="far fa-heart"></i>
                    <span>89</span>
                    <span>点赞</span>
                </button>
                <button class="action-btn comment-btn">
                    <i class="far fa-comment"></i>
                    <span>24</span>
                    <span>评论</span>
                </button>
                <button class="action-btn share-btn">
                    <i class="far fa-share-square"></i>
                    <span>分享</span>
                </button>
                <button class="action-btn save-btn">
                    <i class="far fa-bookmark"></i>
                    <span>收藏</span>
                </button>
                <button class="action-btn report-btn">
                    <i class="far fa-flag"></i>
                    <span>举报</span>
                </button>
            </div>
        </div>
        
        <!-- 评论区 -->
        <div class="comments-section">
            <div class="comments-header">
                <div class="comments-title">
                    评论区
                    <span class="comments-count">24</span>
                </div>
                <div class="sort-comments">
                    <i class="fas fa-sort me-1"></i> 最新评论
                </div>
            </div>
            
            <!-- 评论输入框 -->
            <div class="comment-input-container">
                <img src="https://picsum.photos/100/100?random=99" alt="当前用户头像" class="user-avatar">
                <div class="comment-input-wrapper">
                    <textarea class="comment-input" rows="3" placeholder="分享你的想法..."></textarea>
                    <div class="comment-actions">
                        <button class="cancel-btn">取消</button>
                        <button class="submit-btn">发布评论</button>
                    </div>
                </div>
            </div>
            
            <!-- 评论列表 -->
            <div class="comments-list">
                <!-- 评论1 -->
                <div class="comment-item">
                    <img src="https://picsum.photos/100/100?random=60" alt="评论者头像" class="user-avatar">
                    <div class="comment-content-wrapper">
                        <div class="comment-header">
                            <div class="comment-author">阳光灿烂</div>
                            <div class="comment-time">1天前</div>
                        </div>
                        <div class="comment-text">
                            我也有过类似的经历，辞职后的那段时间虽然焦虑，但也让我有机会重新认识自己，找到真正适合的方向。相信你也能找到属于自己的道路！
                        </div>
                        <div class="comment-actions">
                            <div class="comment-action like-comment">
                                <i class="far fa-heart"></i>
                                <span>15</span>
                            </div>
                            <div class="comment-action reply-to-comment">
                                <i class="far fa-reply"></i>
                                <span>回复</span>
                            </div>
                        </div>
                        
                        <!-- 回复列表 -->
                        <div class="replies-list">
                            <!-- 回复1 -->
                            <div class="reply-item">
                                <img src="https://picsum.photos/100/100?random=1" alt="回复者头像" class="user-avatar">
                                <div class="reply-content-wrapper">
                                    <div class="comment-header">
                                        <div class="comment-author">匿名用户753 <span class="reply-to">回复 阳光灿烂</span></div>
                                        <div class="comment-time">12小时前</div>
                                    </div>
                                    <div class="reply-text">
                                        谢谢你的鼓励，现在确实很焦虑，希望能尽快调整过来
                                    </div>
                                    <div class="comment-actions">
                                        <div class="comment-action like-reply">
                                            <i class="far fa-heart"></i>
                                            <span>5</span>
                                        </div>
                                        <div class="comment-action reply-to-reply">
                                            <i class="far fa-reply"></i>
                                            <span>回复</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- 回复输入框 -->
                            <div class="reply-input-container" style="display: none;">
                                <img src="https://picsum.photos/100/100?random=99" alt="当前用户头像" class="user-avatar">
                                <div class="comment-input-wrapper">
                                    <textarea class="reply-input" rows="2" placeholder="回复 @阳光灿烂..."></textarea>
                                    <div class="reply-actions">
                                        <button class="cancel-btn reply-btn">取消</button>
                                        <button class="submit-btn reply-btn">回复</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 评论2 -->
                <div class="comment-item">
                    <img src="https://picsum.photos/100/100?random=61" alt="评论者头像" class="user-avatar">
                    <div class="comment-content-wrapper">
                        <div class="comment-header">
                            <div class="comment-author">过来人</div>
                            <div class="comment-time">2天前</div>
                        </div>
                        <div class="comment-text">
                            建议先休息一两周调整状态，然后列出自己的优势和兴趣，再针对性地寻找机会。不要急于做出决定，给自己一些时间和空间。
                        </div>
                        <div class="comment-actions">
                            <div class="comment-action like-comment liked">
                                <i class="fas fa-heart"></i>
                                <span>23</span>
                            </div>
                            <div class="comment-action reply-to-comment">
                                <i class="far fa-reply"></i>
                                <span>回复</span>
                            </div>
                        </div>
                        
                        <!-- 回复列表 -->
                        <div class="replies-list">
                            <!-- 回复1 -->
                            <div class="reply-item">
                                <img src="https://picsum.photos/100/100?random=70" alt="回复者头像" class="user-avatar">
                                <div class="reply-content-wrapper">
                                    <div class="comment-header">
                                        <div class="comment-author">职场小白 <span class="reply-to">回复 过来人</span></div>
                                        <div class="comment-time">1天前</div>
                                    </div>
                                    <div class="reply-text">
                                        这个建议很实用，我当时辞职后就是太急着找下家，结果又跳进了另一个坑
                                    </div>
                                    <div class="comment-actions">
                                        <div class="comment-action like-reply">
                                            <i class="far fa-heart"></i>
                                            <span>8</span>
                                        </div>
                                        <div class="comment-action reply-to-reply">
                                            <i class="far fa-reply"></i>
                                            <span>回复</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 评论3 -->
                <div class="comment-item">
                    <img src="https://picsum.photos/100/100?random=62" alt="评论者头像" class="user-avatar">
                    <div class="comment-content-wrapper">
                        <div class="comment-header">
                            <div class="comment-author">自由职业者</div>
                            <div class="comment-time">2天前</div>
                        </div>
                        <div class="comment-text">
                            我三年前也做了同样的决定，现在是一名自由职业者。虽然不稳定，但至少不用看老板脸色，时间也自由。如果你有一技之长，可以考虑这条路。
                        </div>
                        <div class="comment-actions">
                            <div class="comment-action like-comment">
                                <i class="far fa-heart"></i>
                                <span>17</span>
                            </div>
                            <div class="comment-action reply-to-comment">
                                <i class="far fa-reply"></i>
                                <span>回复</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 加载更多评论 -->
            <div class="text-center mt-4">
                <button class="btn btn-light border load-more-comments">
                    <i class="fas fa-spinner fa-spin me-1"></i> 加载更多评论
                </button>
            </div>
        </div>
        
        <!-- 相关推荐 -->
        <div class="related-posts">
            <h3 class="related-title">相关推荐</h3>
            <div class="related-list">
                <!-- 推荐1 -->
                <div class="related-card">
                    <div class="related-content">
                        <div class="related-text">
                            辞职后在家待了三个月，终于找到了自己真正想做的事情，分享一下我的经历
                        </div>
                        <div class="related-meta">
                            <span><i class="far fa-clock me-1"></i> 5天前</span>
                            <span><i class="far fa-comment me-1"></i> 32</span>
                        </div>
                    </div>
                </div>
                
                <!-- 推荐2 -->
                <div class="related-card">
                    <img src="https://picsum.photos/400/300?random=30" alt="职场书籍推荐" class="related-image">
                    <div class="related-content">
                        <div class="related-text">
                            推荐几本帮助我度过职业迷茫期的书籍，希望对大家有帮助
                        </div>
                        <div class="related-meta">
                            <span><i class="far fa-clock me-1"></i> 1周前</span>
                            <span><i class="far fa-comment me-1"></i> 18</span>
                        </div>
                    </div>
                </div>
                
                <!-- 推荐3 -->
                <div class="related-card">
                    <div class="related-content">
                        <div class="related-text">
                            从996大厂裸辞后，我开了一家小咖啡馆，现在的生活很充实
                        </div>
                        <div class="related-meta">
                            <span><i class="far fa-clock me-1"></i> 2周前</span>
                            <span><i class="far fa-comment me-1"></i> 45</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 发布树洞浮动按钮 -->
    <button class="float-post-btn" title="发布新树洞">
        <i class="fas fa-plus"></i>
    </button>
    
    <!-- 图片查看器 -->
    <div class="image-viewer" id="imageViewer">
        <div class="viewer-content">
            <button class="close-viewer" id="closeViewer">
                <i class="fas fa-times"></i>
            </button>
            <div class="viewer-nav">
                <button class="viewer-btn prev-image">
                    <i class="fas fa-chevron-left"></i>
                </button>
                <button class="viewer-btn next-image">
                    <i class="fas fa-chevron-right"></i>
                </button>
            </div>
            <img src="" alt="大图预览" class="viewer-image" id="viewerImage">
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // 点赞功能
        document.querySelector('.like-btn').addEventListener('click', function() {
            const icon = this.querySelector('i');
            const countElem = this.querySelector('span');
            let count = parseInt(countElem.textContent);
            
            if (this.classList.contains('liked')) {
                this.classList.remove('liked');
                icon.classList.remove('fas');
                icon.classList.add('far');
                countElem.textContent = count - 1;
            } else {
                this.classList.add('liked');
                icon.classList.remove('far');
                icon.classList.add('fas');
                countElem.textContent = count + 1;
            }
        });
        
        // 收藏功能
        document.querySelector('.save-btn').addEventListener('click', function() {
            const icon = this.querySelector('i');
            
            if (this.classList.contains('saved')) {
                this.classList.remove('saved');
                icon.classList.remove('fas');
                icon.classList.add('far');
                alert('已取消收藏');
            } else {
                this.classList.add('saved');
                icon.classList.remove('far');
                icon.classList.add('fas');
                alert('收藏成功');
            }
        });
        
        // 分享功能
        document.querySelector('.share-btn').addEventListener('click', function() {
            alert('分享功能：可以分享到微信、微博、QQ等平台');
        });
        
        // 举报功能
        document.querySelector('.report-btn').addEventListener('click', function() {
            alert('举报功能：此内容将被提交给管理员审核');
        });
        
        // 评论功能 - 聚焦评论框
        document.querySelector('.comment-btn').addEventListener('click', function() {
            document.querySelector('.comment-input').focus();
        });
        
        // 评论点赞功能
        document.querySelectorAll('.like-comment').forEach(btn => {
            btn.addEventListener('click', function() {
                const icon = this.querySelector('i');
                const countElem = this.querySelector('span');
                let count = parseInt(countElem.textContent);
                
                if (this.classList.contains('liked')) {
                    this.classList.remove('liked');
                    icon.classList.remove('fas');
                    icon.classList.add('far');
                    countElem.textContent = count - 1;
                } else {
                    this.classList.add('liked');
                    icon.classList.remove('far');
                    icon.classList.add('fas');
                    countElem.textContent = count + 1;
                }
            });
        });
        
        // 回复点赞功能
        document.querySelectorAll('.like-reply').forEach(btn => {
            btn.addEventListener('click', function() {
                const icon = this.querySelector('i');
                const countElem = this.querySelector('span');
                let count = parseInt(countElem.textContent);
                
                if (this.classList.contains('liked')) {
                    this.classList.remove('liked');
                    icon.classList.remove('fas');
                    icon.classList.add('far');
                    countElem.textContent = count - 1;
                } else {
                    this.classList.add('liked');
                    icon.classList.remove('far');
                    icon.classList.add('fas');
                    countElem.textContent = count + 1;
                }
            });
        });
        
        // 回复评论功能
        document.querySelectorAll('.reply-to-comment').forEach(btn => {
            btn.addEventListener('click', function() {
                // 找到对应的回复输入框
                const replyInput = this.closest('.comment-content-wrapper').querySelector('.reply-input-container');
                
                // 隐藏其他所有回复框
                document.querySelectorAll('.reply-input-container').forEach(input => {
                    if (input !== replyInput) {
                        input.style.display = 'none';
                    }
                });
                
                // 切换当前回复框显示状态
                replyInput.style.display = replyInput.style.display === 'flex' ? 'none' : 'flex';
                
                // 如果显示则聚焦
                if (replyInput.style.display === 'flex') {
                    replyInput.querySelector('.reply-input').focus();
                }
            });
        });
        
        // 回复回复功能
        document.querySelectorAll('.reply-to-reply').forEach(btn => {
            btn.addEventListener('click', function() {
                // 找到最近的评论项
                const commentItem = this.closest('.comment-item, .reply-item');
                // 找到评论项中的回复输入框，如果没有则创建
                let replyInput = commentItem.querySelector('.reply-input-container');
                
                if (!replyInput) {
                    // 创建新的回复输入框
                    const authorName = commentItem.querySelector('.comment-author').textContent.split(' ')[0];
                    const newReplyInput = document.createElement('div');
                    newReplyInput.className = 'reply-input-container';
                    newReplyInput.style.display = 'flex';
                    newReplyInput.innerHTML = `
                        <img src="https://picsum.photos/100/100?random=99" alt="当前用户头像" class="user-avatar">
                        <div class="comment-input-wrapper">
                            <textarea class="reply-input" rows="2" placeholder="回复 @${authorName}..."></textarea>
                            <div class="reply-actions">
                                <button class="cancel-btn reply-btn">取消</button>
                                <button class="submit-btn reply-btn">回复</button>
                            </div>
                        </div>
                    `;
                    
                    // 添加到回复列表
                    const repliesList = this.closest('.replies-list') || this.closest('.comment-content-wrapper').appendChild(document.createElement('div'));
                    if (!this.closest('.replies-list')) {
                        repliesList.className = 'replies-list';
                    }
                    repliesList.appendChild(newReplyInput);
                    
                    // 绑定取消按钮事件
                    newReplyInput.querySelector('.cancel-btn').addEventListener('click', function() {
                        newReplyInput.style.display = 'none';
                    });
                    
                    // 绑定提交按钮事件
                    newReplyInput.querySelector('.submit-btn').addEventListener('click', function() {
                        alert('回复成功');
                        newReplyInput.style.display = 'none';
                    });
                    
                    // 聚焦
                    newReplyInput.querySelector('.reply-input').focus();
                } else {
                    // 切换显示状态
                    replyInput.style.display = replyInput.style.display === 'flex' ? 'none' : 'flex';
                    
                    // 如果显示则聚焦
                    if (replyInput.style.display === 'flex') {
                        replyInput.querySelector('.reply-input').focus();
                    }
                }
            });
        });
        
        // 取消回复
        document.querySelectorAll('.cancel-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                this.closest('.reply-input-container, .comment-input-container').querySelector('textarea').value = '';
                if (this.closest('.reply-input-container')) {
                    this.closest('.reply-input-container').style.display = 'none';
                }
            });
        });
        
        // 提交评论
        document.querySelector('.submit-btn:not(.reply-btn)').addEventListener('click', function() {
            const commentInput = document.querySelector('.comment-input');
            if (commentInput.value.trim() === '') {
                alert('请输入评论内容');
                return;
            }
            alert('评论发布成功');
            commentInput.value = '';
        });
        
        // 提交回复
        document.querySelectorAll('.submit-btn.reply-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                const replyInput = this.closest('.reply-input-container').querySelector('.reply-input');
                if (replyInput.value.trim() === '') {
                    alert('请输入回复内容');
                    return;
                }
                alert('回复成功');
                replyInput.value = '';
                this.closest('.reply-input-container').style.display = 'none';
            });
        });
        
        // 加载更多评论
        document.querySelector('.load-more-comments').addEventListener('click', function() {
            const originalText = this.innerHTML;
            this.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i> 加载中...';
            
            // 模拟加载延迟
            setTimeout(() => {
                this.innerHTML = originalText;
                alert('已加载全部评论');
            }, 1500);
        });
        
        // 图片查看器功能
        const imageViewer = document.getElementById('imageViewer');
        const viewerImage = document.getElementById('viewerImage');
        const closeViewer = document.getElementById('closeViewer');
        const postImages = document.querySelectorAll('.post-image');
        let currentImageIndex = 0;
        
        // 打开图片查看器
        postImages.forEach((img, index) => {
            img.addEventListener('click', function() {
                currentImageIndex = index;
                viewerImage.src = this.src;
                imageViewer.classList.add('show');
                document.body.style.overflow = 'hidden'; // 禁止背景滚动
            });
        });
        
        // 关闭图片查看器
        closeViewer.addEventListener('click', function() {
            imageViewer.classList.remove('show');
            document.body.style.overflow = ''; // 恢复背景滚动
        });
        
        // 点击查看器外部关闭
        imageViewer.addEventListener('click', function(e) {
            if (e.target === this) {
                imageViewer.classList.remove('show');
                document.body.style.overflow = '';
            }
        });
        
        // 下一张图片
        document.querySelector('.next-image').addEventListener('click', function(e) {
            e.stopPropagation();
            currentImageIndex = (currentImageIndex + 1) % postImages.length;
            viewerImage.src = postImages[currentImageIndex].src;
        });
        
        // 上一张图片
        document.querySelector('.prev-image').addEventListener('click', function(e) {
            e.stopPropagation();
            currentImageIndex = (currentImageIndex - 1 + postImages.length) % postImages.length;
            viewerImage.src = postImages[currentImageIndex].src;
        });
        
        // 发布新树洞按钮
        document.querySelector('.float-post-btn').addEventListener('click', function() {
            alert('打开发布树洞的表单');
        });
    </script>
</body>
</html>

